const mixin = {
  data() {
    return {}
  },

  methods: {
    //获取所有页面的按钮权限
    getBtnControl: function (id) {
      return new Promise((resolve, reject) => {
        axios
          .get(this.$locat.upmsUser_userSystem, {
            params: {
              menuid: id
            }
          })
          .then(({ data = {}, code }) => {
            console.log(data)
            if (code == 0) {
              resolve(data)
            }
          })
      })
    },
    //重置表单
    resetForm(formName) {
      console.log(formName, this.$refs[formName])
      this.$refs[formName].resetFields()
    },
    //表单验证
    pubSubmitForm(formName, fn) {
      // console.log(formName, fn, this);
      return new Promise((resolve, reject) => {
        this.$refs[formName].validate((valid) => {
          console.log(valid)
          if (valid) {
            // console.log(typeof fn);
            let type = typeof fn
            if (type == 'string') {
              fn ? this[fn]() : ''
            }
          } else {
            console.log('error submit!!')
          }
          resolve(valid)
        })
      })
    }
  }
}

export default mixin
